package Day11_08_05;

import java.util.Scanner;

public class Number {
	public static void Negative() throws NegativeNumber{
		System.out.println("输入被开方的数字:");
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();
		if (num < 0) {
			throw new NegativeNumber();
		}
		if (num > 0) {
			double result = Math.sqrt(num);
			System.out.println(num + " 平方根是：" + result);
		}
		if (num == 0) {
			System.out.println("0多没意思啊");
		}
	}
	
	public static void main(String[] args) {
		try {
			Negative();
		} catch (NegativeNumber e) {
			System.out.println("输入错误，不能对负数求平方根");
		}

	}

}
